(function () {
    "use strict";

    angular.module('core').factory('financeiroService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {

        var _getResumoReceber = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetResumoReceber')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartVencidosVencerPorMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartVencidosVencerPorMes')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartEvolucaoPorMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartEvolucaoPorMes')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartReceberPorCategoriaMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartReceberPorCategoriaMes')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getContasReceberPorCentroCusto = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetContasReceberPorCentroCusto')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartReceberPorTipoPagamentoMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartReceberPorTipoPagamentoMes')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };


        var _getResumoPagar = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetResumoPagar')
               .success(function (data) { deferred.resolve(data); })
               .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartPagarVencidosVencerPorMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartPagarVencidosVencerPorMes')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartPagarEvolucaoPorMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartPagarEvolucaoPorMes')
               .success(function (data) { deferred.resolve(data); })
               .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartPagarPorCategoriaMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartPagarPorCategoriaMes')
               .success(function (data) { deferred.resolve(data); })
               .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getContasPagarPorCentroCusto = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetContasPagarPorCentroCusto')
               .success(function (data) { deferred.resolve(data); })
               .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _getChartPagarPorTipoPagamentoMes = function () {
            var deferred = $q.defer();
            $http.post('/ReportFinanceiro/GetChartPagarPorTipoPagamentoMes')
               .success(function (data) { deferred.resolve(data); })
               .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };


        return {
            getResumoReceber: _getResumoReceber,
            getChartVencidosVencerPorMes: _getChartVencidosVencerPorMes,
            getChartEvolucaoPorMes: _getChartEvolucaoPorMes,
            getChartReceberPorCategoriaMes: _getChartReceberPorCategoriaMes,
            getChartReceberPorTipoPagamentoMes: _getChartReceberPorTipoPagamentoMes,
            getContasReceberPorCentroCusto: _getContasReceberPorCentroCusto,

            getResumoPagar: _getResumoPagar,
            getChartPagarVencidosVencerPorMes: _getChartPagarVencidosVencerPorMes,
            getChartPagarEvolucaoPorMes: _getChartPagarEvolucaoPorMes,
            getChartPagarPorCategoriaMes: _getChartPagarPorCategoriaMes,
            getContasPagarPorCentroCusto: _getContasPagarPorCentroCusto,
            getChartPagarPorTipoPagamentoMes: _getChartPagarPorTipoPagamentoMes
        };
    }

})();